(function (config) {
    config = config || {};
    var util = {
        getCookie: function (a) {
            var b = document.cookie.match("(?:^|;)\\s*" + a + "=([^;]*)");
            return (b && b[1]) ? decodeURIComponent(b[1]) : ""
        },
        escapeHTML: function (b) {
            var a = document.createElement("div"),
            c = document.createTextNode(b);
            a.appendChild(c);
            return a.innerHTML
        }
    };
    var isDaily = (window.location.hostname.indexOf("daily") != -1);
    var nick = util.getCookie("_nk_"),
    isLogin = (util.getCookie("login") == "true"),
    timestamp = new Date().getTime(),
    loginUrl = "http://login.tmall.com";
    var href = location.href;
    if (/^http.*(\/member\/login\.jhtml)$/i.test(href)) {
        href = ""
    }
    var redirectUrl = config.redirectUrl || href;
    if (document.all) {}

    if (redirectUrl) {
        if (isDaily) {
          
            loginUrl += "?offlineshop=1&isDaily=1&redirect_url=" + encodeURIComponent(redirectUrl)
        }else{
            loginUrl += "?offlineshop=1&redirect_url=" + encodeURIComponent(redirectUrl)
        }
    }
    var logoutUrl = "https://login.taobao.com/member/logout.jhtml?f=top&redirectURL=http://login.tmall.com/?redirect_url=" + encodeURIComponent("" + encodeURIComponent(redirectUrl));
    var regUrl = "http://register.tmall.com/";
    var messageUrl = config.memberServer + "/message/list_private_msg.htm?t=" + timestamp;
    var jianghuUrl = "http://jianghu.taobao.com/admin/home.htm?t=" + timestamp;
    if (isDaily) {
        logoutUrl = "https://login.daily.taobao.net/member/logout.jhtml?f=top&redirectURL=https://login.daily.taobao.net/member/login.jhtml?redirect_url%3D" + encodeURIComponent("" + encodeURIComponent(redirectUrl));
        regUrl += "?isDaily=1"
    }
    var z = "";
    if ((window.location.href.indexOf("taobao.com") != -1) || (window.location.href.indexOf("taobao.net") != -1)) {
        if (nick) {
            z = '\u60a8\u597d\uff0c' + util.escapeHTML(unescape(nick.replace(/\\u/g, "%u"))) + '\uff01<a id="J_Logout" href="' + logoutUrl + '" target="_top">\u9000\u51fa</a>';
        } else {
            z = '\u60a8\u597d\uff0c\u6b22\u8fce\u6765\u6dd8\u5b9d\uff01<a href="' + loginUrl + '" target="_top">\u8bf7\u767b\u5f55</a>';
        }
    } else {
        if (isLogin) {
            z = '\u60a8\u597d\uff0c' + util.escapeHTML(unescape(nick.replace(/\\u/g, "%u"))) + '\uff01<a id="J_Logout" href="' + logoutUrl + '" target="_top">\u9000\u51fa</a>';
        } else {
            z = '\u60a8\u597d\uff0c\u6b22\u8fce\u6765\u6dd8\u5b9d\uff01<a href="' + loginUrl + '" target="_top">\u8bf7\u767b\u5f55</a>';
        }
    }
    document.write(z)
})({
    memberServer: "http://member1.taobao.com",
    loginServer: "https://login.taobao.com",
    redirectUrl: "",
    logoutUrl: ""
});